package com.duomai.myapplication.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.duomai.myapplication.R;
import com.example.admin.SQLite.LunTan;
import com.example.admin.SQLite.dao.LunTanDao;
import com.example.admin.adapter.ForumAdapter;
import com.example.admin.SQLite.Complaint;
import com.example.admin.SQLite.SqLiteOpenHelper;
import com.example.admin.activity.ForumDetailActivity;
import com.example.admin.adapter.ForumLunTanAdapter;
import com.example.admin.base.BaseActivity;

import java.util.ArrayList;

//论坛
public class ForumActivity extends BaseActivity {

    LunTanDao lunTanDao;
    ForumLunTanAdapter mAdapter;
    RecyclerView recyclerView;

    @Override
    public void setContentView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_forum);
        lunTanDao = new LunTanDao(this);
        mAdapter = new ForumLunTanAdapter();
        recyclerView = findViewById(R.id.recyclerView);
        recyclerView.setAdapter(mAdapter);
        mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                startActivity(new Intent(ForumActivity.this, ForumDetailActivity.class)
                        .putExtra("bean", mAdapter.getItem(position)));
            }
        });
        findViewById(R.id.addForum).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(ForumActivity.this, ForumAddActivity.class));
            }
        });
        findViewById(R.id.tvMine).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(ForumActivity.this, ForumMineActivity.class));
            }
        });

    }

    @Override
    public void setInitView() {

    }

    @Override
    public void onStart() {
        super.onStart();
        getdata();
    }

    private void getdata() {
        ArrayList<LunTan> list = lunTanDao.getComPlans();
        mAdapter.setNewData(list);
    }

}